<?php
require_once (APPLICATION_DIR."/application/model/Admin_submenu.php");
class Admin_submenu extends DataObjects_Admin_submenu
{	
	function getSubMenuTitle($parent_id)
	{
		$this->selectAdd();
		$this->selectAdd("menu_id,menu_action, menu_index,menu_title, menu_parent_id");
		$this->whereAdd();
		$this->whereAdd("menu_parent_id = $parent_id");
		$this->orderBy();
		$this->orderBy("menu_index");
		$this->find();
		return $this;
	}
	
	function getAllSubMenu()
	{
		$this->selectAdd();
		$this->selectAdd("menu_id, menu_action, menu_title, menu_index, menu_parent_id");
		$this->whereAdd();
		$this->orderBy();
		$this->orderBy("menu_parent_id, menu_index");
		$this->find();		
		return $this;
	}
	
	function prepareLeftPane($topmenu_id)
	{
		$smarty		= DRX::load("smarty");
		
		$topmenu	= new Admin_topmenu();
		$topMenuInfo= $topmenu->getMenuInfoByID($topmenu_id);
		$topMenuInfo->fetch();
		$page_action= $topMenuInfo->menu_action;
		$smarty->assign("action",$page_action);
		
		$leftpane	= $this->getSubMenuTitle($topmenu_id);
		$smarty->assign("leftpane",$leftpane);
		
		$leftmenu 	= $smarty->fetch("admin/leftpane.tpl");
		$smarty->assign("leftmenu",$leftmenu);
		
		$has_left_menu	= true;
		$smarty->assign("has_left_menu",$has_left_menu);
	}
	
	function preparePageTitle($topmenu_id,$submenu_index)
	{
		$smarty		= DRX::load("smarty");
		$this->selectAdd("menu_title");
		$this->whereAdd();
		$this->whereAdd("(menu_parent_id = $topmenu_id) and (menu_index = $submenu_index)");
		$this->find();
		$this->fetch();
		$page_title = $this->menu_title;
		$smarty->assign("page_title",$page_title);
	}
}
?>